# -*- coding: utf-8 -*-
# @Time     : 2021/11/30 10:51
# @Author   : wljess
# @File     : 守护进程.py
# @Describe : 
# @Software : PyCharm

import time
from multiprocessing import Process


def son1():
    while True:
        time.sleep(0.5)
        print("son1 is_alive")


def son2():
    for i in range(5):
        time.sleep(1)
        print("son2 is running")

if __name__ == '__main__':
    p1 = Process(target=son1)
    p2 = Process(target=son2)
    # 守护线程的开启必须在创建完线程对象，启动线程之间进行设置
    p1.daemon = True
    p1.start()
    p2.start()

    time.sleep(2)
    print("主进程运行结束...")
